<?php
class EvaluateApp extends MemberbaseApp
{
	var $_eval_mod;

	function __construct(){
		parent::__construct();
		$this->EvaluateApp();
	}

	function EvaluateApp(){
		$this->_eval_mod=&m('evaluate');
	}


	function index(){
		$user_info=$this->visitor->get();
		$sample_mod=&m('sample');
		/* 获取品牌 */
		$brand_mod =& m('brand');
		if($user_info['role']==USER_MERCHANDISER_ADMIN)
		{
			$mod_company_manager=&m("company_manager");
			$brand_where=" AND brand.company_id in(select company_id from {$mod_company_manager->table} where uid={$this->visitor->get('user_id')})";
		}
		$brand_list = $brand_mod->find(array(
				'conditions' => 'if_show = 1'.$brand_where,
				'join'=>"belong_company",
				'order' => 'brand_name ASC'
		));
		$this->assign('brand_list', $brand_list);

		/* 获取买手 */
		$buyer_mod =& m('member');
		$buyer_list = $buyer_mod->find(array(
				'conditions' => 'if_show = 1 and activation=1 and role='.USER_CLIENT,
				'order' => 'user_name ASC'
		));
		$this->assign('buyer_list', $buyer_list);
		/* 获取工厂 */
		$factory_list = array();
		$factory_mod =& m('factory_info');
		$factory_list = $factory_mod->find(array(
				'join'=>'belongs_factory_member',
				'order' => 'factory_name ASC',
				'conditions'=>'activation=1'
		));

		$this->assign('factory_list', $factory_list);
			
		$style_mod =& m('style');
		$this->assign('style_list', $style_mod->find(array('conditions'=>'if_show = 1', 'order'=>'style_name ASC')));

		/* 获取跟单 */
		$merch_mod =& m('member');
		$merch_list = $merch_mod->find(array(
				'conditions' => 'role = ' . USER_MERCHANDISER . ' AND if_show = 1' . ($this->visitor->get('role') == USER_ASSISTANT ? ' AND user_id in (' . $this->visitor->get('merchandiser') . ')' : ''),
				'order' => 'user_name',
		));
		$this->assign('merch_list', $merch_list);

		/* 获取查询条件 */
		$conditions = array();
		$sample_sn = empty($_GET['sample_sn']) ? null : trim($_GET['sample_sn']);
		if ($sample_sn) {
			$conditions[] = "sample_sn like '%".$sample_sn."%'";
		}
		$arrival_date_start = empty($_GET['arrival_date_start']) ? 0 : strtotime(trim($_GET['arrival_date_start']));
		if ($arrival_date_start) {
			$conditions[] = "arrival_date >= $arrival_date_start";
		}
		$arrival_date_end = empty($_GET['arrival_date_end']) ? 0 : strtotime(trim($_GET['arrival_date_end']));
		if ($arrival_date_end) {
			$conditions[] = "arrival_date <= $arrival_date_end";
		}
		$brand_id = empty($_GET['brand_id']) ? 0 : intval($_GET['brand_id']);
		if ($brand_id) {
			$conditions[] = "sample.brand_id = $brand_id";
		}
		$buyer_id = empty($_GET['buyer_id']) ? 0 : intval($_GET['buyer_id']);
		if ($buyer_id) {
			$conditions[] = "sample.buyer_id = $buyer_id";
		}
		$factory_id = empty($_GET['factory_id']) ? 0 : intval($_GET['factory_id']);
		if ($factory_id) {
			$conditions[] = "sample.factory_id = $factory_id";
		}
		if ($user_info['role'] == USER_MANAGER) {
			$this->assign('user_manage', USER_MANAGER);
			$merch_id = empty($_GET['merch_id']) ? 0 : intval($_GET['merch_id']);
			if ($merch_id) {
				$conditions[] = "merchandiser_id = $merch_id";
			}
			$conditions[]="1=1";
		}elseif ($user_info['role']==USER_MERCHANDISER_ADMIN){
			$this->assign('user_manage',USER_MERCHANDISER_ADMIN);
			$merch_id = empty($_GET['merch_id']) ? 0 : intval($_GET['merch_id']);
			if ($merch_id) {
				$conditions[] = "merchandiser_id = $merch_id";
			}
			$mod_company_manager=&m("company_manager");
			$brand_mod =& m('brand');
			$conditions[]="sample.brand_id in(select brand_id from {$brand_mod->table} where company_id in(select company_id from {$mod_company_manager->table} where uid={$this->visitor->get('user_id')}))";
		}
		else {
			$merch_id = $user_info['user_id'];
			$conditions[] = "merchandiser_id = $merch_id";
		}
		$conditions = ($conditions ? ' AND ' : '') . implode(' AND ', $conditions);


		/* 获取排序 */
		$order = empty($_GET['order']) ? 'add_time DESC' : str_replace('-', ' ', trim($_GET['order']));
		if(empty($_GET['order'])){
			$_GET['order']='add_time DESC';
		}

		if ($order != 'arrival_date DESC' || $order != 'arrival_date ASC') {
			$order .= ', arrival_date DESC';
		}
		$page = $this->_get_page();
		$sample_list = $sample_mod->find(array(
				'fields' => '*, sample.status, sample.description',
				'conditions' => 'sample.status '.db_create_in(array(SAMPLE_STATUS_SEND_SAMPLE,SAMPLE_STATUS_STOCK)). $conditions.' and evaluate_time is null',
				'join' => 'belongs_brand,belongs_merchandiser,belongs_style,belongs_factory,has_evaluate',
				'order' => $order,
				'limit' => $page['limit'],
				'count' => true
		));
		foreach ($sample_list as $key => $val) {
			$buy_info=$merch_mod->get($val['buyer_id']);
			if (!empty($buy_info)){
				$sample_list[$key]['member_name']=$buy_info['user_name'];
			}
			$to_factory_date=!empty($val['to_factory_date'])?intval($val['to_factory_date']):0;
			if ($val['status'] == SAMPLE_STATUS_SEND_SAMPLE || $val['status'] ==SAMPLE_STATUS_STOCK) {
				if (!$val['send_sample_date']) {
					$end_time = time();
				} else {
					$end_time = $val['send_sample_date'];
				}
				$sample_list[$key]['sample_made_days'] = intval(($end_time - $val['arrival_date']) / 60 / 60 / 24) + 1;
			}
			else
			{
				$sample_list[$key]['sample_made_days'] =!empty($val['arrival_date'])? intval((time() - $val['arrival_date']) / 60 / 60 / 24) + 1:0;
			}
			//安照板期排序
			$order_str=str_replace('-', ' ', trim($_GET['order']));
				
			if($order_str=="sample_made_days ASC")
			{
				$this->usortSample($sample_list,"asc");
			}
			elseif($order_str=="sample_made_days DESC")
			{
				$this->usortSample($sample_list,"desc");
					
			}
		}
		$page['item_count'] = $sample_mod->getCount();
		$this->_format_page($page);
		$this->assign('page_info', $page);
		$this->assign('user',$user_info);
		$this->assign('sample_list',$sample_list);
		$this->display('evaluate.index.html');
		$this->_curlocal("待评价样板");
	}
	
	function usortSample(&$sample_list,$order)
	{
		if(empty($sample_list)){
			return false;
		}
		$cmp_arr=array();
		foreach($sample_list as $item)
		{
			$cmp_arr[$item["sample_id"]]=$item["sample_made_days"];
		}
	
		if($order=="asc")
		{
			asort($cmp_arr);
		}
		elseif($order=="desc")
		{
			arsort($cmp_arr);
		}
		foreach($cmp_arr as $key=>$item)
		{
			$cmp_arr[$key]=$sample_list[$key];
		}
		$sample_list=$cmp_arr;
		return true;
	}

	function history_evaluated(){
		$user_info=$this->visitor->get();
		$sample_mod=&m('sample');
		
		/* 获取工厂 */
		$factory_list = array();
		$factory_mod =& m('factory_info');
		$factory_list = $factory_mod->find(array(
				'join'=>'belongs_factory_member',
				'order' => 'factory_name ASC',
				'conditions'=>'activation=1'
		));
		
		$this->assign('factory_list', $factory_list);
			
		/* 获取跟单 */
		$merch_mod =& m('member');
		$merch_list = $merch_mod->find(array(
				'conditions' => 'role = ' . USER_MERCHANDISER . ' AND if_show = 1' . ($this->visitor->get('role') == USER_ASSISTANT ? ' AND user_id in (' . $this->visitor->get('merchandiser') . ')' : ''),
				'order' => 'user_name',
		));
		$this->assign('merch_list', $merch_list);
		
		$this->assign('speed_list',array('3'=>Lang::get('good_evaluate'),'2'=>Lang::get('common_evaluate'),'1'=>Lang::get('bad_evaluate')));
		$this->assign('price_list',array('3'=>Lang::get('good_evaluate'),'2'=>Lang::get('common_evaluate'),'1'=>Lang::get('bad_evaluate')));
		$this->assign('demand_list',array('3'=>Lang::get('good_evaluate'),'2'=>Lang::get('common_evaluate'),'1'=>Lang::get('bad_evaluate')));
		$this->assign('coop_list',array('3'=>Lang::get('good_evaluate'),'2'=>Lang::get('common_evaluate'),'1'=>Lang::get('bad_evaluate')));
		/* 获取查询条件 */
		$conditions = array();
		$sample_sn = empty($_GET['sample_sn']) ? null : trim($_GET['sample_sn']);
		if ($sample_sn) {
			$conditions[] = "sample_sn like '%".$sample_sn."%'";
		}
// 		$arrival_date_start = empty($_GET['arrival_date_start']) ? 0 : strtotime(trim($_GET['arrival_date_start']));
// 		if ($arrival_date_start) {
// 			$conditions[] = "arrival_date >= $arrival_date_start";
// 		}
// 		$arrival_date_end = empty($_GET['arrival_date_end']) ? 0 : strtotime(trim($_GET['arrival_date_end']));
// 		if ($arrival_date_end) {
// 			$conditions[] = "arrival_date <= $arrival_date_end";
// 		}
		$factory_id = empty($_GET['factory_id']) ? 0 : intval($_GET['factory_id']);
		if ($factory_id) {
			$conditions[] = "sample.factory_id = $factory_id";
		}
		
		//年月份查询条件
		$year=empty($_GET['year']) ? 0 : intval($_GET['year']);
		$month=empty($_GET['month']) ? 0 : intval($_GET['month']);
		$years=array();
		$months=array();
		$this_year = $year ? $year : date('Y');
		$this_month = $month ? $month : date('m');
		for($i = $this_year - 10; $i <= $this_year+1; $i++) {
			$years[$i] = $i;
		}
		$months=array(1,2,3,4,5,6,7,8,9,10,11,12);
		$this->assign('years', $years);
		$this->assign('this_year', $this_year);
		$this->assign('months', $months);
		$this->assign('this_month', $this_month);
		if ($year || $month){
			$conditions[]='evaluate_time >= ' . strtotime($this_year .'-'.$this_month.'-1') . ' AND evaluate_time <= ' . strtotime($this_year .'-'.$this_month.'-31');
		}
		//评价查询条件
		$sample_speed=empty($_GET['sample_speed']) ? 0 : intval($_GET['sample_speed']);
		if ($sample_speed){
			$conditions[]="sample_speed=".$sample_speed;
		}
		$sample_price=empty($_GET['sample_price']) ? 0 : intval($_GET['sample_price']);
		if ($sample_price){
			$conditions[]="sample_price=".$sample_price;
		}
		$sample_demand=empty($_GET['sample_demand']) ? 0 : intval($_GET['sample_demand']);
		if ($sample_demand){
			$conditions[]="sample_demand=".$sample_demand;
		}
		$sample_cooperate=empty($_GET['sample_cooperate']) ? 0 : intval($_GET['sample_cooperate']);
		if ($sample_cooperate){
			$conditions[]="sample_cooperate=".$sample_cooperate;
		}
		if ($user_info['role'] == USER_MANAGER) {
			$this->assign('user_manage', USER_MANAGER);
			$merch_id = empty($_GET['merch_id']) ? 0 : intval($_GET['merch_id']);
			if ($merch_id) {
				$conditions[] = "merchandiser_id = $merch_id";
			}
			$conditions[]="1=1";
		}elseif ($user_info['role']==USER_MERCHANDISER_ADMIN){
			$this->assign('user_manage',USER_MERCHANDISER_ADMIN);
			$merch_id = empty($_GET['merch_id']) ? 0 : intval($_GET['merch_id']);
			if ($merch_id) {
				$conditions[] = "merchandiser_id = $merch_id";
			}
			$mod_company_manager=&m("company_manager");
			$brand_mod =& m('brand');
			$conditions[]="sample.brand_id in(select brand_id from {$brand_mod->table} where company_id in(select company_id from {$mod_company_manager->table} where uid={$this->visitor->get('user_id')}))";
		}
		else {
			$merch_id = $user_info['user_id'];
			$conditions[] = "merchandiser_id = $merch_id";
		}
		$conditions = ($conditions ? ' AND ' : '') . implode(' AND ', $conditions);
		
		
		/* 获取排序 */
		$order = empty($_GET['order']) ? 'add_time DESC' : str_replace('-', ' ', trim($_GET['order']));
		if(empty($_GET['order'])){
			$_GET['order']='add_time DESC';
		}
		
		if ($order != 'arrival_date DESC' || $order != 'arrival_date ASC') {
			$order .= ', arrival_date DESC';
		}
		$page = $this->_get_page();
		$sample_list = $sample_mod->find(array(
				'fields' => '*, sample.status, sample.description',
				'conditions' => 'sample.status '.db_create_in(array(SAMPLE_STATUS_SEND_SAMPLE,SAMPLE_STATUS_STOCK)). $conditions.' and evaluate_time is not null',
				'join' => 'belongs_brand,belongs_merchandiser,belongs_factory,has_evaluate',
				'order' => $order,
				'limit' => $page['limit'],
				'count' => true
		));
		foreach ($sample_list as $key => $val) {
			$member_info=$merch_mod->get($val['eval_user_id']);
			if (!empty($member_info)){
				$sample_list[$key]['evaluate_user']=$member_info['user_name'];
			}
			$to_factory_date=!empty($val['to_factory_date'])?intval($val['to_factory_date']):0;
			if ($val['status'] == SAMPLE_STATUS_SEND_SAMPLE || $val['status'] ==SAMPLE_STATUS_STOCK) {
				if (!$val['send_sample_date']) {
					$end_time = time();
				} else {
					$end_time = $val['send_sample_date'];
				}
				$sample_list[$key]['sample_made_days'] = intval(($end_time - $val['arrival_date']) / 60 / 60 / 24) + 1;
			}
			else
			{
				$sample_list[$key]['sample_made_days'] =!empty($val['arrival_date'])? intval((time() - $val['arrival_date']) / 60 / 60 / 24) + 1:0;
			}
			//安照板期排序
			$order_str=str_replace('-', ' ', trim($_GET['order']));
		
			if($order_str=="sample_made_days ASC")
			{
				$this->usortSample($sample_list,"asc");
			}
			elseif($order_str=="sample_made_days DESC")
			{
				$this->usortSample($sample_list,"desc");
					
			}
		}
		$page['item_count'] = $sample_mod->getCount();
		$this->_format_page($page);
		$this->assign('page_info', $page);
		$this->assign('user',$user_info);
		$this->assign('evaluate_list',$sample_list);
		$this->display('evaluate.list.html');
		$this->_curlocal(Lang::get('history_evaluated'));
	}
	
	
	//评价样板
	function evaluate(){
		$user=$this->visitor->get();
		$sample_id=isset($_GET['sample_id'])?$_GET['sample_id']:0;
		$sample_mod=&m('sample');
		if (!$sample_id){
			$this->show_warning("sample_not_exsit");
			return;
		}
		$sample_info=$sample_mod->get_info($sample_id);
		if (empty($sample_info)){
			$this->show_warning("sample_not_exsit");
			return;
		}
		//$evaluate_info=array('sample_speed'=>2,'sample_price'=>2,'sample_cooperate'=>2,'sample_demand'=>2);
		if (!IS_POST){
			$this->assign('evaluate',$sample_info);
			$this->_curlocal(Lang::get('evaluate_list'), 'index.php?app=evaluate&act=index', Lang::get('sample_evaluate'));
			$this->display('evaluate.form.html');
		}else{
			$data=array();
			$data['evaluate_time']=gmtime();
			$data['evaluate_content']=trim($_POST['evaluate_content']);
			$data['sample_speed']=$_POST['sample_speed'];
			$data['sample_price']=$_POST['sample_price'];
			$data['sample_cooperate']=$_POST['sample_cooperate'];
			$data['sample_demand']=$_POST['sample_demand'];
			$data['sample_id']=$sample_id;
			$data['eval_user_id']=$user['user_id'];
			$eval_id=$this->_eval_mod->add($data);
			if (!$eval_id){
				$this->show_warning($this->_eval_mod->get_error());
				return;
			}
			$this->show_message("evaluate_success",Lang::get('history_evaluated'),'index.php?app=evaluate&act=history_evaluated');
		}
	}
	
	
	//查看评价
	function show(){
		$eval_id=isset($_GET['eval_id'])?$_GET['eval_id']:0;
		if (!$eval_id){
			$this->show_warning("evaluate_not_exsit");
			return;
		}
		$eval_info=$this->_eval_mod->get(array(
			'conditions'=>'eval_id='.$eval_id,
			'join'=>'belongs_to_sample'		
		));
		if (empty($eval_info)){
			$this->show_warning("evaluate_not_exsit");
			return;
		}
		//$evaluate_info=array('sample_speed'=>2,'sample_price'=>2,'sample_cooperate'=>2,'sample_demand'=>2);
		$this->assign('evaluate',$eval_info);
		$this->_curlocal(Lang::get('history_evaluated'), 'index.php?app=evaluate&act=history_evaluated', Lang::get('evaluate_show'));
		$this->display('evaluate.view.html');
	}
	
	
	//评价统计
	function eval_total(){
		$user_info=$this->visitor->get();
		$factory_mod=&m('factory_info');
		$sample_mod=&m('sample');
		$year = intval($_GET['year']);
		$month = intval($_GET['month']);
		$years=array();
		$months=array();
		$this_year = $year ? $year : date('Y');
		$this_month = $month ? $month : date('m');
		for($i = $this_year - 10; $i <= $this_year+1; $i++) {
			$years[$i] = $i;
		}
		$months=array(1,2,3,4,5,6,7,8,9,10,11,12);
		$this->assign('years', $years);
		$this->assign('this_year', $this_year);
		$this->assign('months', $months);
		$this->assign('this_month', $this_month);
		$total_list=$factory_mod->find(array(
			'join'=>'belongs_factory_member',
			'conditions' => 'if_show = 1 and activation=1 and role='.USER_FACTORY,
			'order' => 'factory_name ASC'
		));
		if (!empty($total_list)){
			foreach ($total_list as $key=>$val){
				if ($user_info['role']==USER_MERCHANDISER){
					$con=" and merchandiser_id=".$user_info['user_id'];
				}
				$samples = $sample_mod->find(array(
						'join'=>'has_evaluate',
						'conditions' => 'factory_id = ' . $val['factory_id'] . ' and status '.db_create_in(array(SAMPLE_STATUS_SEND_SAMPLE,SAMPLE_STATUS_STOCK)).' AND evaluate_time >= ' . strtotime($this_year .'-'.$this_month.'-1') . ' AND evaluate_time <= ' . strtotime($this_year .'-'.$this_month.'-31').$con,
				));
				$total_list[$key]['quantity'] = count($samples);
				$eval_num = array();
				foreach ($samples as $k => $v) {
					switch (intval(date('m', $v['evaluate_time']))) {
						case 1 :
							switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 2 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 3 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 4 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 5 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 6 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 7 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 8 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 9 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 10 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 11 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
						case 12 :
					switch ($v['sample_speed']){
								case 3 :
									$eval_num['good_speed_num']++;
									break;
								case 2 :
									$eval_num['common_speed_num']++;
									break;
								case 1 :
									$eval_num['bad_speed_num']++;
									break;
							}
							switch ($v['sample_price']){
								case 3 :
									$eval_num['good_price_num']++;
									break;
								case 2 :
									$eval_num['common_price_num']++;
									break;
								case 1 :
									$eval_num['bad_price_num']++;
									break;
							}
							switch ($v['sample_demand']){
								case 3 :
									$eval_num['good_demand_num']++;
									break;
								case 2 :
									$eval_num['common_demand_num']++;
									break;
								case 1 :
									$eval_num['bad_demand_num']++;
									break;
							}
							switch ($v['sample_cooperate']){
								case 3 :
									$eval_num['good_cooperate_num']++;
									break;
								case 2 :
									$eval_num['common_cooperate_num']++;
									break;
								case 1 :
									$eval_num['bad_cooperate_num']++;
									break;
							}
							break;
					}
				}
				$total_list[$key]['good_speed_num']=$eval_num['good_speed_num'];
				$total_list[$key]['common_speed_num']=$eval_num['common_speed_num'];
				$total_list[$key]['bad_speed_num']=$eval_num['bad_speed_num'];
				$total_list[$key]['good_price_num']=$eval_num['good_price_num'];
				$total_list[$key]['common_price_num']=$eval_num['common_price_num'];
				$total_list[$key]['bad_price_num']=$eval_num['bad_price_num'];
				$total_list[$key]['good_demand_num']=$eval_num['good_demand_num'];
				$total_list[$key]['common_demand_num']=$eval_num['common_demand_num'];
				$total_list[$key]['bad_demand_num']=$eval_num['bad_demand_num'];
				$total_list[$key]['good_cooperate_num']=$eval_num['good_cooperate_num'];
				$total_list[$key]['common_cooperate_num']=$eval_num['common_cooperate_num'];
				$total_list[$key]['bad_cooperate_num']=$eval_num['bad_cooperate_num'];
			}
		}
		$this->assign('total_list',$total_list);
		$this->_curlocal(Lang::get('evaluate_total'));
		$this->display('evaluate.total.html');
	}
}